package com.itic.mall.system.users.collection.service;

import com.itic.appbase.framework.common.constants.DBConst;
import com.itic.appbase.framework.common.service.CrudService;
import com.itic.mall.system.inter.users.collection.persistence.dao.UsersCollectDao;
import com.itic.mall.system.inter.users.collection.persistence.model.UsersCollect;
import com.itic.mall.system.inter.users.collection.persistence.model.UsersCollectExample;
import com.itic.mall.system.inter.users.collection.persistence.model.UsersCollectExample.Criteria;
import com.itic.mall.system.users.collectionitem.service.UsersCollectItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
@Transactional
public class UsersCollectService
     extends CrudService<UsersCollectDao,UsersCollect,UsersCollectExample> {
    @Autowired
    private UsersCollectDao usersCollectDao;
    @Autowired
    private UsersCollectItemService usersCollectItemService;

    public List<UsersCollect> getUsersCollectByGoodsId(String userId,String goodsId){
    	UsersCollectExample example = new UsersCollectExample();
    	Criteria criteria = example.createCriteria();
    	criteria.andIsEffectiveEqualTo(DBConst.TRUE);
    	criteria.andUserIdEqualTo(userId);
    	criteria.andGoodsIdEqualTo(goodsId);
    	return this.list(example);
    }

    
    public List<UsersCollect> getUsersCollectByStoreId(String userId,String storeId){
    	UsersCollectExample example = new UsersCollectExample();
    	Criteria criteria = example.createCriteria();
    	criteria.andIsEffectiveEqualTo(DBConst.TRUE);
    	criteria.andUserIdEqualTo(userId);
    	criteria.andStoreIdEqualTo(storeId);
    	return this.list(example);
    }
    
    
}